package com.foryou.wechat.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.foryou.wechat.entity.IndexBackEntity;
import com.foryou.wechat.mapper.IndexBackMapper;
import com.foryou.wechat.service.IndexBackService;
import com.foryou.wechat.utils.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class IndexBackServiceImpl implements IndexBackService {

    private final IndexBackMapper indexBackMapper;

    public IndexBackServiceImpl(IndexBackMapper indexBackMapper) {
        this.indexBackMapper = indexBackMapper;
    }

    @Override
    public Response getIndexBackList() {
        List<IndexBackEntity> selectList = indexBackMapper.selectList(new QueryWrapper<IndexBackEntity>().eq("enabled", 1));
        List<String> indexList = new ArrayList<>();
        selectList.forEach(e->{
            indexList.add(e.getUrl());
        });
        return Response.success(indexList);
    }
}
